﻿/*
// ==============================================================================
// Copyright(C) 2011 NCS Pte Ltd
//
// SYSTEM NAME			: MOH Online Collaboration Portal
// COMPONENT ID			: NCS.OCP.SharePointComponent.fun@work heart@work
// COMPONENT DESC		: OCP fun@work heart@work javascripts 
//
// CREATED DATE/BY	    : 28-06-2011 / zhang zu meng
// DEPENDENCIES         : 
//
// REVISION HISTORY     :
// DATE/BY  ISSUE#/SR#/CS/PM#/OTHERS    DESCRIPTION OF CHANGE
//
// ==============================================================================
*/
(function ($) {
    $.fn.likeDefaults = {
        staffid: 0,
        spobjectid: 0,
        objecttype: "",
        url: "",
        desc: "",
        albumid: 0,
        username: "",
        success: null
    }
    $.fn.likeCommit = function (options) {

        var likeopt = $.extend({}, $.fn.likeDefaults, options);

        $.support.cors = true;
        $.ajax({
            type: "GET",
            url: likeopt.url + "?staffId=" + likeopt.staffid + "&objectId=" + likeopt.spobjectid + "&objectType="+likeopt.objecttype,
            //data: '{"staffId":"' + likeopt.staffid + '","objectId":"' + likeopt.spobjectid + '","objectType":"' + likeopt.objecttype + '"}',
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            cache: false,
            success: likeopt.success,
            error: function (a, b, c) { alert(c); },
            failure: function (msg) {
                alert(msg);
            }
        });
    }

    $.fn.getLikes = function (options) {
        var getlike = $.extend({}, $.fn.likeDefaults, options);

        $.support.cors = true;
        $.ajax({
            type: "GET",
            url: getlike.url + "?staffId=" + getlike.staffid + "&feedPostId=" + getlike.spobjectid + "&objectType=" + getlike.objecttype,
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            cache: false,
            success: getlike.success,
            error: function (a, b, c) { alert(c); },
            failure: function (msg) {
                alert(msg);
            }
        });
    }
})(jQuery);